package com.quanyan.place.thread;

import com.quanyan.place.biz.ISearchService;
import com.quanyan.place.entity.vo.PlaceUnitSalePlan;
import com.quanyan.place.mapper.TbBizPlaceMapper;
import com.quanyan.place.service.PlaceInnerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by youxiaojia on 2016/8/4.
 */
public class CallBackSolrIndex {
//    private static Logger logger = LoggerFactory.getLogger(CallBackSolrIndex.class);
    private static ExecutorService executorService = Executors.newSingleThreadExecutor();
    public static void receiveResult(PlaceInnerService placeInnerService, PlaceUnitSalePlan placeUnitSalePlan, List<String> ids, TbBizPlaceMapper tbBizPlaceMapper,ISearchService searchService,Integer flag){
        //获取最低价
        placeInnerService.getMinPrice(placeUnitSalePlan);
        // 增加索引
        if(flag == 1){
//            try {
//                logger.debug("______________________延迟5分钟后开始添加索引______________________");
//                Thread.sleep(300000);//
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
            executorService.execute(new SolrIndexThread(placeUnitSalePlan.getPlaceId(), ids, tbBizPlaceMapper, searchService));
        }else if(flag == 2){
            executorService.execute(new SolrIndexThread(placeUnitSalePlan.getPlaceId(), ids, tbBizPlaceMapper, searchService));
        }else if(flag ==3){
            //do nothing
        }


    }
}
